Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

interface System.​Numerics.​INumberBase<​TSelf>

Assembly: System.Runtime

Implemented Interfaces

Defines the base of other number types.

Properties

static TSelf
One
Gets the value <c>1</c> for the type.
static int
Radix
Gets the radix, or base, for the type.
static TSelf
Zero
Gets the value <c>0</c> for the type.

Methods

static TSelf
Abs​(TSelf value)
Computes the absolute of a value.
Returns The absolute of <paramref name="value" /> .
value The value for which to get its absolute.
static TSelf
CreateChecked​(TOther value)
Creates an instance of the current type from a value, throwing an overflow exception for any values that fall outside the representable range of the current type.
Returns An instance of <typeparamref name="TSelf" /> created from <paramref name="value" /> .
value The value that's used to create the instance of <typeparamref name="TSelf" /> .
static TSelf
CreateSaturating​(TOther value)
Creates an instance of the current type from a value, saturating any values that fall outside the representable range of the current type.
Returns An instance of <typeparamref name="TSelf" /> created from <paramref name="value" /> , saturating if <paramref name="value" /> falls outside the representable range of <typeparamref name="TSelf" /> .
value The value that is used to create the instance of <typeparamref name="TSelf" /> .
static TSelf
CreateTruncating​(TOther value)
Creates an instance of the current type from a value, truncating any values that fall outside the representable range of the current type.
Returns An instance of <typeparamref name="TSelf" /> created from <paramref name="value" /> , truncating if <paramref name="value" /> falls outside the representable range of <typeparamref name="TSelf" /> .
value The value that is used to create the instance of <typeparamref name="TSelf" /> .
static bool
IsCanonical​(TSelf value)
Determines if a value is in its canonical representation.
Returns <see langword="true" /> if <paramref name="value" /> is in its canonical representation; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsComplexNumber​(TSelf value)
Determines if a value represents a complex number.
Returns <see langword="true" /> if <paramref name="value" /> is a complex number; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsEvenInteger​(TSelf value)
Determines if a value represents an even integral number.
Returns <see langword="true" /> if <paramref name="value" /> is an even integer; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsFinite​(TSelf value)
Determines if a value is finite.
Returns <see langword="true" /> if <paramref name="value" /> is finite; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsImaginaryNumber​(TSelf value)
Determines if a value represents a pure imaginary number.
Returns <see langword="true" /> if <paramref name="value" /> is a pure imaginary number; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsInfinity​(TSelf value)
Determines if a value is infinite.
Returns <see langword="true" /> if <paramref name="value" /> is infinite; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsInteger​(TSelf value)
Determines if a value represents an integral number.
Returns <see langword="true" /> if <paramref name="value" /> is an integer; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsNaN​(TSelf value)
Determines if a value is NaN.
Returns <see langword="true" /> if <paramref name="value" /> is NaN; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsNegative​(TSelf value)
Determines if a value represents a negative real number.
Returns <see langword="true" /> if <paramref name="value" /> represents negative zero or a negative real number; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsNegativeInfinity​(TSelf value)
Determines if a value is negative infinity.
Returns <see langword="true" /> if <paramref name="value" /> is negative infinity; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsNormal​(TSelf value)
Determines if a value is normal.
Returns <see langword="true" /> if <paramref name="value" /> is normal; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsOddInteger​(TSelf value)
Determines if a value represents an odd integral number.
Returns <see langword="true" /> if <paramref name="value" /> is an odd integer; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsPositive​(TSelf value)
Determines if a value represents zero or a positive real number.
Returns <see langword="true" /> if <paramref name="value" /> represents (positive) zero or a positive real number; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsPositiveInfinity​(TSelf value)
Determines if a value is positive infinity.
Returns <see langword="true" /> if <paramref name="value" /> is positive infinity; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsRealNumber​(TSelf value)
Determines if a value represents a real number.
Returns <see langword="true" /> if <paramref name="value" /> is a real number; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsSubnormal​(TSelf value)
Determines if a value is subnormal.
Returns <see langword="true" /> if <paramref name="value" /> is subnormal; otherwise, <see langword="false" /> .
value The value to be checked.
static bool
IsZero​(TSelf value)
Determines if a value is zero.
Returns <see langword="true" /> if <paramref name="value" /> is zero; otherwise, <see langword="false" /> .
value The value to be checked.
static TSelf
MaxMagnitude​(TSelf x, TSelf y)
Compares two values to compute which has the greater magnitude.
Returns <paramref name="x" /> if it has a greater magnitude than <paramref name="y" /> ; otherwise, <paramref name="y" /> .
x The value to compare with <paramref name="y" /> .
y The value to compare with <paramref name="x" /> .
static TSelf
MaxMagnitudeNumber​(TSelf x, TSelf y)
Compares two values to compute which has the greater magnitude and returning the other value if an input is <c>NaN</c> .
Returns <paramref name="x" /> if it has a greater magnitude than <paramref name="y" /> ; otherwise, <paramref name="y" /> .
x The value to compare with <paramref name="y" /> .
y The value to compare with <paramref name="x" /> .
static TSelf
MinMagnitude​(TSelf x, TSelf y)
Compares two values to compute which has the lesser magnitude.
Returns <paramref name="x" /> if it has a lesser magnitude than <paramref name="y" /> ; otherwise, <paramref name="y" /> .
x The value to compare with <paramref name="y" /> .
y The value to compare with <paramref name="x" /> .
static TSelf
MinMagnitudeNumber​(TSelf x, TSelf y)
Compares two values to compute which has the lesser magnitude and returning the other value if an input is <c>NaN</c> .
Returns <paramref name="x" /> if it has a lesser magnitude than <paramref name="y" /> ; otherwise, <paramref name="y" /> .
x The value to compare with <paramref name="y" /> .
y The value to compare with <paramref name="x" /> .
static TSelf
MultiplyAddEstimate​(TSelf left, TSelf right, TSelf addend)
Computes an estimate of ( <paramref name="left" /> * <paramref name="right" /> ) + <paramref name="addend" /> .
Returns An estimate of ( <paramref name="left" /> * <paramref name="right" /> ) + <paramref name="addend" /> .
left The value to be multiplied with <paramref name="right" /> .
right The value to be multiplied with <paramref name="left" /> .
addend The value to be added to the result of <paramref name="left" /> multiplied by <paramref name="right" /> .
static TSelf
Parse​(ReadOnlySpan<​byte> utf8Text, Globalization.​NumberStyles style, IFormatProvider? provider)
Parses a span of UTF-8 characters into a value.
Returns The result of parsing <paramref name="utf8Text" /> .
utf8Text The span of UTF-8 characters to parse.
style A bitwise combination of number styles that can be present in <paramref name="utf8Text" /> .
provider An object that provides culture-specific formatting information about <paramref name="utf8Text" /> .
static TSelf
Parse​(ReadOnlySpan<​char> s, Globalization.​NumberStyles style, IFormatProvider? provider)
Parses a span of characters into a value.
Returns The result of parsing <paramref name="s" /> .
s The span of characters to parse.
style A bitwise combination of number styles that can be present in <paramref name="s" /> .
provider An object that provides culture-specific formatting information about <paramref name="s" /> .
static TSelf
Parse​(string s, Globalization.​NumberStyles style, IFormatProvider? provider)
Parses a string into a value.
Returns The result of parsing <paramref name="s" /> .
s The string to parse.
style A bitwise combination of number styles that can be present in <paramref name="s" /> .
provider An object that provides culture-specific formatting information about <paramref name="s" /> .
protected static bool
TryConvertFromChecked​(TOther value, TSelf& result)
protected static bool
TryConvertFromSaturating​(TOther value, TSelf& result)
protected static bool
TryConvertFromTruncating​(TOther value, TSelf& result)
protected static bool
TryConvertToChecked​(TSelf value, TOther& result)
protected static bool
TryConvertToSaturating​(TSelf value, TOther& result)
protected static bool
TryConvertToTruncating​(TSelf value, TOther& result)
static bool
TryParse​(ReadOnlySpan<​byte> utf8Text, Globalization.​NumberStyles style, IFormatProvider? provider, TSelf& result)
static bool
TryParse​(ReadOnlySpan<​char> s, Globalization.​NumberStyles style, IFormatProvider? provider, TSelf& result)
static bool
TryParse​(string s, Globalization.​NumberStyles style, IFormatProvider provider, TSelf& result)